package com.myrslok.set;

import com.myrslok.util.ZipUtil;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.util.jar.Manifest;

public class JArchive extends BasicArchive {

    @NotNull
    private Manifest manifest;

    public JArchive(@NotNull final String jar, @NotNull final String baseDir) {
        this(new File(jar), new File(baseDir));
    }

    public JArchive(@NotNull final File jar, @NotNull final String baseDir) {
        this(jar, new File(baseDir));
    }

    public JArchive(@NotNull final File jar, @NotNull final File baseDir) {
        super(jar, baseDir);
    }

    public JArchive(@NotNull final String jar) {
        super(new File(jar), null);
    }

    public void setManifest(@NotNull final Manifest manifest) {
        this.manifest = manifest;
    }

    @Override
    public void archive() {
        ZipUtil.jar(target, getResources(), manifest);
    }

    @Override
    public void extractTo(@NotNull final File dest) {
        ZipUtil.unjar(target, dest);
    }

}
